<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/1/17
 * Time: 15:09
 */
class Model{
    //操作的表
    public $table;
    //驱动
    public $db;
    //构造函数
    public function __construct($table=null){
        $this->db = Dbfactory::getDrive();
        $this->db->table = $this->table?$this->table:$table;
    }

    public function run(){
        echo __METHOD__;
    }

    //插入数据
    public function insert($data=null){
        if(is_null($data)){
            halt('插入数据为空');
        }
        return $this->db->insert($data);
    }

    //条件
    public function where($where=null){
        $this->db->where($where);
        return $this;
    }

    //限制条数
    public function limit($limit=null){
        $this->db->limit($limit);
        return $this;
    }

    //查询
    public function select(){
        return $result = $this->db->select();
    }

    //更新
    public function update($data){
        return $this->db->update($data);
    }

    //删除
    public function delete(){
        return $this->db->delete();
    }
}